#!/usr/bin/env bash

source ./config/env.sh
clear

echo -e "\033[1;33m ----------------------------------- etcd -----------------------------------\033[0m"
for master_ip in ${MASTER_IP}
do
    echo -e "${master_ip}::\c";ssh root@${master_ip} "hostname"
    ssh root@${master_ip} "systemctl status etcd | grep 'Active:'"
done


echo -e "\033[1;33m ----------------------------------- kube-apiserver -----------------------------------\033[0m"
for master_ip in ${MASTER_IP}
do
    echo -e "${master_ip}::\c";ssh root@${master_ip} "hostname"
    ssh root@${master_ip} "systemctl status kube-apiserver | grep 'Active:'"
done


echo -e "\033[1;33m ----------------------------------- kube-scheduler -----------------------------------\033[0m"
for master_ip in ${MASTER_IP}
do
    echo -e "${master_ip}::\c";ssh root@${master_ip} "hostname"
    ssh root@${master_ip} "systemctl status kube-scheduler | grep 'Active:'"
done


echo -e "\033[1;33m ----------------------------------- kube-controller_manager -----------------------------------\033[0m"
for master_ip in ${MASTER_IP}
do
    echo -e "${master_ip}::\c";ssh root@${master_ip} "hostname"
    ssh root@${master_ip} "systemctl status kube-controller-manager | grep 'Active:'"
done


echo -e "\033[1;33m ----------------------------------- flanneld -----------------------------------\033[0m"
for master_ip in ${MASTER_IP}
do
    echo -e "${master_ip}::\c";ssh root@${master_ip} "hostname"
    ssh root@${master_ip} "systemctl status flanneld   | grep 'Active:'"
done

echo -e "\033[1;33m ----------------------------------- keepalived  -----------------------------------\033[0m"
for master_ip in ${MASTER_IP}
do
    echo -e "${master_ip}::\c";ssh root@${master_ip} "hostname"
    ssh root@${master_ip} "systemctl status keepalived  | grep 'Active:'"
done


echo -e "\033[1;33m ----------------------------------- haproxy   -----------------------------------\033[0m"
for master_ip in ${MASTER_IP}
do
    echo -e "${master_ip}::\c";ssh root@${master_ip} "hostname"
    ssh root@${master_ip} "systemctl status haproxy   | grep 'Active:'"
done

echo -e "\033[1;33m ################ Current cluster state ####################\033[0m"
${K8S_BIN_DIR}/kubectl get cs